<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //ES5写法
       /*  function Phone(brand, price) {
            this.brand = brand;
            this.price = price;
        }
        //添加方法
        Phone.prototype.call = function() {
            console.log('我能够打电话');
        }
        //实例化对象
        let Huawei = new Phone('华为X3', 5999);
        Huawei.call();
        console.log(Huawei); */

        //ES6写法
        class Shouji{
            //构造方法,constructor一定名字不能变
            constructor(brand, price) {
                this.brand = brand;
                this.price = price;
            }
            //方法必须使用改语法，不能使用ES5 的对象完整形式
            call() {
                console.log('1加手机非常棒!!!');
            }
        }
        let onePlus = new Shouji('1加手机', 1999);
        onePlus.call();
        console.log(onePlus);
    </script>
</body>
</html>